<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增子章节')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <style>
        .file-preview-thumbnails , .file-preview-frame{
            height: 500px !important;
        }
    </style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-sonSection-add">
        <!--TODO:修改为下拉框 遍历数据库中父章节名字-->
        <div class="form-group">
            <!--<label class="col-sm-3 control-label">父章节ID：</label>-->
            <label class="col-sm-3 control-label">父章节名称：</label>
            <div class="col-sm-8">
                <!--<input name="sectionId" class="form-control" type="text">-->
                <select name="fatherSection" id="fatherSection" class="form-control m-b">
                    <option th:each="iterStat:${fatherSection}" th:value="${iterStat.sectionName}"
                            th:text="${iterStat.sectionName}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">子章节名称：</label>
            <div class="col-sm-8">
                <input name="sonSectionName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">章节视频：</label>
            <div class="col-sm-8">
                <input type="hidden" name="sonSectionVideo">
                <div class="file-loading">
                    <input class="form-control file-upload" id="sonSectionVideo" name="file" type="file">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否允许观看：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                    <input type="radio" th:id="${'isWatch_' + dict.dictCode}" name="isWatch"
                           th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${'isWatch_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">子章节序列：</label>
            <div class="col-sm-8">
                <select name="sonSequence" class="form-control m-b" th:with="type=${@dict.getType('chapter_sort')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">子章节备注：</label>
            <div class="col-sm-8">
                <textarea name="sonSectionRemark" class="form-control"></textarea>
            </div>
        </div>
        <!-- <div class="form-group">
             <label class="col-sm-3 control-label">乐观锁：</label>
             <div class="col-sm-8">
                 <input name="revision" class="form-control" type="text">
             </div>
         </div>
         <div class="form-group">
             <label class="col-sm-3 control-label">逻辑删除：</label>
             <div class="col-sm-8">
                 <input name="deleted" class="form-control" type="text">
             </div>
         </div>-->
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "course/sonSection"
    $("#form-sonSection-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-sonSection-add').serialize());
        }
    }

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })
</script>
</body>
</html>